package com.lesson3.singleton;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/8/27 10:53
 * 静态内部类
 */
public class Type3
{
    public static void main(String[] args)
    {
        Singleton5 instance = Singleton5.getInstance();
        Singleton5 instance1 = Singleton5.getInstance();
        System.out.println(instance.hashCode()==instance1.hashCode());
    }
}

class Singleton5{
    private static volatile Singleton5 singleton5;

    private Singleton5(){

    }

    private static class SingleInstance{
        private static final Singleton5 SINGLETON_5 = new Singleton5();
    }

    public synchronized static Singleton5 getInstance(){
        return SingleInstance.SINGLETON_5;
    }
}
